//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package rtk.olinkstar;

import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public class NmeaAnalyzer {
    public static final String TAG = "NmeaAnalyzer";
    public static final String TAG99 = "netBleTest";
    public static final String TAG5 = "NmeaAnalyzer5";
    public int srcId = 0;
    private double latitude = -1.0D;
    private double longitude = -1.0D;
    private double altitude = -10911.0D;
    private double speed = -1.0D;
    private double bearing = -1.0D;
    private double bearingBGI = -1.0D;
    private String strUtcTime;
    private int mode = 0;
    private double dop;
    private int u_stars = 0;
    private double hEPE = -1.0D;
    private double wEPE = -1.0D;
    private double pdop = -1.0D;
    private double vdop = -1.0D;
    private double hdop = -1.0D;
    private String latitudeNS = "";
    private String longitudeEW = "";
    private CopyOnWriteArrayList<MySatellite> satellites = new CopyOnWriteArrayList();
    private CopyOnWriteArrayList<MySatellite> t_satellites = new CopyOnWriteArrayList();
    private String strGGA = "";
    private int[] usedInFixTable = new int[500];
    private int baseDelay = 0;
    private int baseLine = 0;
    private int baseGPSN = 0;
    private int baseBDSN = 0;
    private int baseElvGpsSnr = 0;
    private int baseElvBdsSnr = 0;
    private int roverGPSN = 0;
    private int roverBDSN = 0;
    private int roverElvGpsSnr = 0;
    private int roverElvBdsSnr = 0;
    private int roverUsedGPSN = 0;
    private int roverUsedBDSN = 0;
    private double sdkAccuracy;

    public NmeaAnalyzer(int id) {
        this.srcId = id;
    }

    boolean CheckSum(byte[] buff) {
        if(buff != null && buff.length >= 5) {
            boolean result = false;
            byte var6 = buff[1];

            int i;
            for(i = 2; i < buff.length && buff[i] != 42; ++i) {
                var6 ^= buff[i];
            }

            String sCheck = Integer.toHexString(var6).toUpperCase();
            byte[] hh = new byte[2];
            if((var6 & 240) != 0) {
                hh[0] = sCheck.getBytes()[0];
                hh[1] = sCheck.getBytes()[1];
            } else {
                hh[0] = 48;
                hh[1] = sCheck.getBytes()[0];
            }

            return i + 4 != buff.length - 1?false:(buff[i] == 42 && buff[i + 3] == 13 && buff[i + 4] == 10?hh[0] == buff[i + 1] && hh[1] == buff[i + 2]:false);
        } else {
            return false;
        }
    }

    public boolean analyze(String nmea, NmeaCallback callback) {
        boolean isASCIIEncoded = false;
        if(!nmea.startsWith("$GP") && !nmea.startsWith("$GN") && !nmea.startsWith("$BD") && !nmea.startsWith("$GB")) {
            return isASCIIEncoded;
        } else {
            isASCIIEncoded = true;
            if(!this.CheckSum(nmea.getBytes())) {
                return isASCIIEncoded;
            } else if(nmea.length() < 6) {
                return isASCIIEncoded;
            } else {
                boolean bSend;
                if(!nmea.startsWith("$GPGGA") && !nmea.startsWith("$GNGGA")) {
                    if(nmea.substring(3, 6).equals("GLL")) {
                        bSend = this.analyzeGLL(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.substring(3, 6).equals("GSA")) {
                        bSend = this.analyzeGSA(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.substring(3, 6).equals("GSV")) {
                        RtkService.flagXXGSV = true;
                        bSend = this.analyzeGSV(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.substring(3, 6).equals("RMC")) {
                        RtkService.flagXXRMC = true;
                        bSend = this.analyzeRMC(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.startsWith("$GNBGI")) {
                        Log.d("GNBGI", "解析方位角");
                        bSend = this.analyzeBGI(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.startsWith("$GNEPE")) {
                        bSend = this.analyzeEPE(nmea);
                        if(bSend) {
                            Log.d("SDKGNEPE", "SDKGNEPE: =" + nmea.toString() + "\n:hepe " + this.hEPE + " wepe = " + this.wEPE);
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.startsWith("$GNRDK")) {
                        bSend = this.analyzeRDK(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    } else if(nmea.startsWith("$GNPPS")) {
                        bSend = this.analyzePPS(nmea);
                        if(bSend) {
                            callback.onNmeaOneBroadcast(nmea);
                        }
                    }
                } else {
                    RtkService.flagGPGGA = true;
                    RtkService.nmeaGPGGA = nmea;
                    bSend = this.analyzeGGA(nmea);
                    if(bSend) {
                        callback.onNmeaOneBroadcast(nmea);
                    }
                }

                if(RtkService.flagGPGGA && RtkService.flagXXRMC) {
                    this.strGGA = RtkService.nmeaGPGGA;
                    this.satellites = (CopyOnWriteArrayList)this.t_satellites.clone();
                    this.usedInFixTable = new int[500];
                    this.t_satellites.clear();
                    if(RtkService.flagXXGSV) {
                        RtkService.hasGSV[0] = true;
                        callback.onNmeaUpdate(RtkService.hasGSV);
                    } else {
                        RtkService.hasGSV[0] = false;
                        callback.onNmeaUpdate(RtkService.hasGSV);
                    }

                    RtkService.flagGPGGA = false;
                    RtkService.flagXXGSV = false;
                    RtkService.flagXXRMC = false;
                    RtkService.nmeaGPGGA = "";
                }

                return isASCIIEncoded;
            }
        }
    }

    public String getUtcDateTime() {
        return this.strUtcTime;
    }

    public int getBaseDelay() {
        return this.baseDelay;
    }

    public double getSdkAccuracy() {
        return this.sdkAccuracy;
    }

    public int getBaseLine() {
        return this.baseLine;
    }

    public int getBaseGPSN() {
        return this.baseGPSN;
    }

    public int getBaseBDSN() {
        return this.baseBDSN;
    }

    public int getBaseElvGpsSnr() {
        return this.baseElvGpsSnr;
    }

    public int getBaseElvBdsSnr() {
        return this.baseElvBdsSnr;
    }

    public int getRoverGPSN() {
        return this.roverGPSN;
    }

    public int getRoverBDSN() {
        return this.roverBDSN;
    }

    public int getRoverElvGpsSnr() {
        return this.roverElvGpsSnr;
    }

    public int getRoverElvBdsSnr() {
        return this.roverElvBdsSnr;
    }

    public int getRoverUsedGPSN() {
        return this.roverUsedGPSN;
    }

    public int getRoverUsedBDSN() {
        return this.roverUsedBDSN;
    }

    public double getLatitude() {
        return this.latitudeNS.equals("N")?this.latitude:this.latitude * -1.0D;
    }

    public String getLatitudeNS() {
        return this.latitudeNS;
    }

    public String getLongitudeEW() {
        return this.longitudeEW;
    }

    public int getUstars() {
        return this.u_stars;
    }

    public double getLongitude() {
        return this.longitudeEW.equals("E")?this.longitude:this.longitude * -1.0D;
    }

    public double getAltitude() {
        return this.altitude;
    }

    public double getSpeed() {
        return this.speed;
    }

    public double getBearing() {
        return this.bearing;
    }

    public int getMode() {
        return this.mode;
    }

    public double getDop() {
        return this.dop;
    }

    public double getPdop() {
        return this.pdop;
    }

    public double getVdop() {
        return this.vdop;
    }

    public double getHdop() {
        return this.hdop;
    }

    public double getHepe() {
        return this.hEPE;
    }

    public double getWepe() {
        return this.wEPE;
    }

    public void resetHWepe() {
        this.hEPE = -1.0D;
        this.wEPE = -1.0D;
    }

    public CopyOnWriteArrayList<MySatellite> getSatellites() {
        return (CopyOnWriteArrayList)this.satellites.clone();
    }

    public String getUtcTime() {
        return this.strUtcTime;
    }

    public String getGGA() {
        return this.strGGA;
    }

    private int analyzeMode(String nmea) {
        int index = 0;
        boolean mode2 = false;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(str.toString().equals("")) {
                    byte var9;
                    if(nmea.startsWith("$GPGGA")) {
                        var9 = 0;
                        LOG.D("NmeaAnalyzer", "-GPGGA-mode-kong--: " + var9);
                    } else if(nmea.startsWith("$GNGGA")) {
                        var9 = 0;
                        LOG.D("NmeaAnalyzer", "-GNGGA-mode-kong--: " + var9);
                    }

                    var9 = 0;
                    return var9;
                }

                if(6 == index) {
                    int var8;
                    try {
                        var8 = Integer.parseInt(str.toString());
                    } catch (NumberFormatException var7) {
                        var8 = 0;
                        LOG.E("NmeaAnalyzer", "Illegal mode: " + str);
                    }

                    return var8;
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return 0;
    }

    private boolean analyzeGGA(String nmea) {
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 2:
                        try {
                            this.latitude = Double.parseDouble(str.toString());
                            if(this.latitude > 500.0D) {
                                this.latitude = Buffer.DMToDegree(this.latitude);
                            }
                        } catch (NumberFormatException var14) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal latitude: " + str);
                        }
                        break;
                    case 3:
                        try {
                            this.latitudeNS = str.toString();
                        } catch (Exception var13) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal companyNS: " + str + "  GGA" + nmea);
                        }
                        break;
                    case 4:
                        try {
                            this.longitude = Double.parseDouble(str.toString());
                            if(this.longitude > 500.0D) {
                                this.longitude = Buffer.DMToDegree(this.longitude);
                            }
                        } catch (NumberFormatException var11) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal longitude: " + str + "  GGA" + nmea);
                        }
                        break;
                    case 5:
                        try {
                            this.longitudeEW = str.toString();
                        } catch (Exception var12) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal companyEW: " + str + "  GGA" + nmea);
                        }
                        break;
                    case 6:
                        try {
                            if(str.toString().equals("")) {
                                this.mode = 0;
                            } else {
                                this.mode = Integer.parseInt(str.toString());
                                Log.e("MODE", "MODE         " + this.mode + "  GGA" + nmea);
                            }
                        } catch (Exception var10) {
                            bSend = false;
                            this.mode = 0;
                            LOG.E("NmeaAnalyzer", "Illegal mode: " + str);
                        }
                        break;
                    case 7:
                        try {
                            if(str.toString().equals("")) {
                                this.u_stars = 0;
                            } else {
                                this.u_stars = Integer.parseInt(str.toString());
                                Log.e("MODEE", "MODE     卫星数：    " + this.u_stars);
                            }
                        } catch (Exception var9) {
                            bSend = false;
                            this.u_stars = 0;
                            LOG.E("NmeaAnalyzer", "Illegal mode: " + str);
                        }
                        break;
                    case 8:
                        try {
                            this.dop = Double.parseDouble(str.toString());
                        } catch (Exception var8) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal mode: " + str);
                        }
                        break;
                    case 9:
                        try {
                            this.altitude = Double.parseDouble(str.toString());
                        } catch (Exception var7) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal mode: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private boolean analyzeGLL(String nmea) {
        double latitudeGLL = 0.0D;
        double longitudeGLL = 0.0D;
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 1:
                        try {
                            latitudeGLL = Double.parseDouble(str.toString());
                            if(latitudeGLL > 500.0D) {
                                latitudeGLL = Buffer.DMToDegree(latitudeGLL);
                            }
                        } catch (NumberFormatException var12) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal latitude: " + str);
                        }
                    case 2:
                    default:
                        break;
                    case 3:
                        try {
                            longitudeGLL = Double.parseDouble(str.toString());
                            if(longitudeGLL > 500.0D) {
                                longitudeGLL = Buffer.DMToDegree(longitudeGLL);
                            }
                        } catch (NumberFormatException var11) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal longitude: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private boolean analyzeGSA(String nmea) {
        boolean bSend = true;
        int index = 0;
        int usedSV = 0;
        StringBuffer str = new StringBuffer();
        ArrayList strList = new ArrayList();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("") && index >= 3 && index <= 14) {
                    try {
                        int e = Integer.parseInt(str.toString());
                        if(e > 0 && e < 500) {
                            if(e >= 100 & e < 200) {
                                e += 100;
                            }

                            if(e < 300) {
                                this.usedInFixTable[e] = 1;
                                ++usedSV;
                            }
                        }
                    } catch (NumberFormatException var9) {
                        bSend = false;
                        LOG.E("NmeaAnalyzer", "Illegal prn at index: " + index);
                    }
                }

                strList.add(str.toString());
                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        if(nmea.startsWith("$GPGSA")) {
            this.roverUsedGPSN = usedSV;
        } else {
            this.roverUsedBDSN = usedSV;
        }

        return bSend;
    }

    private boolean analyzeRDK(String nmea) {
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 1:
                    case 2:
                    default:
                        break;
                    case 3:
                        try {
                            this.baseDelay = Integer.parseInt(str.toString());
                            LOG.V("netBleTest", "baseDelay: " + this.baseDelay);
                        } catch (NumberFormatException var12) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer5", "Illegal baseDelay: " + str);
                        }
                        break;
                    case 4:
                        try {
                            this.baseLine = Integer.parseInt(str.toString());
                            LOG.V("NmeaAnalyzer5", "baseLine: " + this.baseLine);
                        } catch (NumberFormatException var11) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer5", "Illegal baseLine: " + str);
                        }
                        break;
                    case 5:
                        try {
                            this.baseGPSN = Integer.parseInt(str.toString());
                            LOG.V("NmeaAnalyzer5", "baseGPSN: " + this.baseGPSN);
                        } catch (NumberFormatException var10) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer5", "Illegal baseGPSN: " + str);
                        }
                        break;
                    case 6:
                        try {
                            this.baseBDSN = Integer.parseInt(str.toString());
                            LOG.V("NmeaAnalyzer5", "baseBDSN: " + this.baseBDSN);
                        } catch (NumberFormatException var9) {
                            LOG.E("NmeaAnalyzer5", "Illegal baseBDSN: " + str);
                        }
                        break;
                    case 7:
                        try {
                            this.baseElvGpsSnr = Integer.parseInt(str.toString());
                            LOG.V("NmeaAnalyzer5", "baseElvGpsSnr: " + this.baseElvGpsSnr);
                        } catch (NumberFormatException var8) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer5", "Illegal baseElvGpsSnr: " + str);
                        }
                        break;
                    case 8:
                        try {
                            this.baseElvBdsSnr = Integer.parseInt(str.toString());
                            LOG.V("NmeaAnalyzer5", "baseElvBdsSnr: " + this.baseElvBdsSnr);
                        } catch (NumberFormatException var7) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal baseElvBdsSnr: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private boolean analyzeGSV(String nmea) {
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();
        int prn = -1;
        double ele = -1.0D;
        double azm = -1.0D;
        double snr = -1.0D;

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) != 44 && !(nmea.charAt(i) == 42 | i == nmea.length() - 1)) {
                str.append(nmea.charAt(i));
            } else {
                if(!str.toString().equals("") && index > 3) {
                    switch(index % 4) {
                    case 0:
                        try {
                            prn = Integer.parseInt(str.toString());
                            if(nmea.startsWith("$GBGSV")) {
                                prn += 100;
                            }

                            if(prn >= 100 && prn < 200) {
                                prn += 100;
                            }
                        } catch (NumberFormatException var17) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal prn: " + str);
                        }
                        break;
                    case 1:
                        try {
                            ele = Double.parseDouble(str.toString());
                        } catch (NumberFormatException var16) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal elevator: " + str);
                        }
                        break;
                    case 2:
                        try {
                            azm = Double.parseDouble(str.toString());
                        } catch (NumberFormatException var15) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal azimuth: " + str);
                        }
                        break;
                    case 3:
                        try {
                            snr = (double)Integer.parseInt(str.toString());
                        } catch (NumberFormatException var14) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal azimuth: " + str);
                        }

                        if(prn > 0 && prn < 500 && prn != -1) {
                            MySatellite sat = new MySatellite();
                            sat.setPrn(prn);
                            sat.setAzimuth(azm);
                            sat.setElevation(ele);
                            sat.setSnr(snr);
                            sat.setUsedInFix(this.usedInFixTable[prn] == 1);
                            this.t_satellites.add(sat);
                            prn = -1;
                            ele = -1.0D;
                            azm = -1.0D;
                            snr = -1.0D;
                        }
                    }
                }

                str.delete(0, str.length());
                ++index;
                if(nmea.charAt(i) == 42) {
                    index = 0;
                }
            }
        }

        this.analyzeRover(this.t_satellites);
        this.analyzeRoverGpsAvgElv(this.t_satellites);
        this.analyzeRoverBdsAvgElv(this.t_satellites);
        LOG.V("NmeaAnalyzerrrr", "--YYYYYYYYYYYYYYYYYYYY----,roverGPSN," + this.roverGPSN + ",roverBDSN," + this.roverBDSN + ",roverElvGpsSnr," + this.roverElvGpsSnr + ",roverElvBdsSnr," + this.roverElvBdsSnr);
        return bSend;
    }

    private boolean analyzeBGI(String nmea) {
        Log.d("bearing", "analyzeBGI：" + nmea);
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 5:
                        try {
                            this.bearingBGI = Double.parseDouble(str.toString());
                            this.bearing = this.bearingBGI;
                        } catch (NumberFormatException var7) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal bearingBGI: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private boolean analyzeRMC(String nmea) {
        Log.e("bearing", "analyzeRMC：" + nmea);
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();
        String utc = "";
        String utcTime = "";
        String utcDate = "";

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 1:
                        utcTime = str.toString();
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    default:
                        break;
                    case 7:
                        try {
                            this.speed = Double.parseDouble(str.toString());
                        } catch (Exception var15) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal speed: " + str);
                        }
                        break;
                    case 8:
                        try {
                            this.bearing = Double.parseDouble(str.toString());
                        } catch (Exception var14) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal bearing: " + str);
                        }
                        break;
                    case 9:
                        utcDate = str.toString();
                        utc = utcDate + utcTime;
                        SimpleDateFormat df1 = new SimpleDateFormat("ddMMyyHHmmss.SSS");
                        SimpleDateFormat df2 = new SimpleDateFormat("yyMMddHHmmss.SSS");
                        SimpleDateFormat df3 = new SimpleDateFormat("yyyyMMddHHmmss.SSS");
                        LOG.V("NmeaAnalyzer5", "--utc:" + utc);

                        try {
                            Date e = df1.parse(utc);
                            utc = df2.format(e);
                            utc = "20" + utc;
                            e = df3.parse(utc);
                            this.strUtcTime = df3.format(e);
                            LOG.V("NmeaAnalyzer5", "--strUtcTime:" + this.strUtcTime);
                            RtkService.currentTime = this.strUtcTime;
                            LOG.V("NmeaAnalyzer", utcTime);
                        } catch (Exception var13) {
                            bSend = false;
                            var13.printStackTrace();
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private boolean analyzeEPE(String nmea) {
        boolean bSend = true;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int ava = 0; ava < nmea.length(); ++ava) {
            if(nmea.charAt(ava) == 44 | nmea.charAt(ava) == 42 | ava == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 1:
                        try {
                            this.hEPE = Double.parseDouble(str.toString());
                        } catch (NumberFormatException var8) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal hEPE: " + str);
                        }
                        break;
                    case 2:
                        try {
                            this.wEPE = Double.parseDouble(str.toString());
                        } catch (NumberFormatException var7) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal wEPE: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(ava));
            }
        }

        if(this.hEPE == -1.0D && this.wEPE == -1.0D) {
            this.sdkAccuracy = -1.0D;
        } else {
            double var9 = this.hEPE * this.hEPE + this.wEPE * this.wEPE;
            var9 = Math.sqrt(var9);
            this.sdkAccuracy = (double)((int)(var9 * Math.pow(10.0D, 3.0D))) / Math.pow(10.0D, 3.0D);
        }

        return bSend;
    }

    private boolean analyzePPS(String nmea) {
        boolean bSend = true;
        boolean pps = false;
        int index = 0;
        StringBuffer str = new StringBuffer();

        for(int i = 0; i < nmea.length(); ++i) {
            if(nmea.charAt(i) == 44 | nmea.charAt(i) == 42 | i == nmea.length() - 1) {
                if(!str.toString().equals("")) {
                    switch(index) {
                    case 1:
                        try {
                            int var9 = Integer.parseInt(str.toString());
                        } catch (NumberFormatException var8) {
                            bSend = false;
                            LOG.E("NmeaAnalyzer", "Illegal PPS: " + str);
                        }
                    }
                }

                ++index;
                str.delete(0, str.length());
            } else {
                str.append(nmea.charAt(i));
            }
        }

        return bSend;
    }

    private void analyzeRover(CopyOnWriteArrayList<MySatellite> sats) {
        int usedInFixGPS = 0;
        int usedInFixBDS = 0;
        Iterator var5 = sats.iterator();

        while(var5.hasNext()) {
            MySatellite sat = (MySatellite)var5.next();
            if(1 == sat.getSystem()) {
                ++usedInFixGPS;
            } else if(2 == sat.getSystem()) {
                ++usedInFixBDS;
            }
        }

        this.roverGPSN = usedInFixGPS;
        this.roverBDSN = usedInFixBDS;
    }

    private void analyzeRoverGpsAvgElv(CopyOnWriteArrayList<MySatellite> sats) {
        if(sats.size() < 6) {
            LOG.V("NmeaAnalyzerrrr", "-001--YYYYYYYYYYYYYYYYYYYY----,roverGPSN," + this.roverGPSN + ",roverBDSN," + this.roverBDSN + ",roverElvGpsSnr," + this.roverElvGpsSnr + ",roverElvBdsSnr," + this.roverElvBdsSnr);
            this.roverElvGpsSnr = 0;
        } else {
            double[] temp = new double[60];
            double[] tempSnr = new double[60];
            int countSat = 0;
            Iterator j = sats.iterator();

            while(j.hasNext()) {
                MySatellite avg = (MySatellite)j.next();
                if(1 == avg.getSystem()) {
                    temp[countSat] = avg.getElevation();
                    tempSnr[countSat] = avg.getSnr();
                    ++countSat;
                }
            }

            int var11;
            for(var11 = 0; var11 < 20; ++var11) {
                LOG.V("NmeaAnalyzerrrr", "----org----FIRST----10-------ELV:" + temp[var11] + "------SNR-----:" + tempSnr[var11]);
            }

            for(var11 = 0; var11 < countSat; ++var11) {
                for(int var12 = var11; var12 < countSat; ++var12) {
                    if(temp[var11] < temp[var12]) {
                        double i = temp[var11];
                        temp[var11] = temp[var12];
                        temp[var12] = i;
                        double tSnr = tempSnr[var11];
                        tempSnr[var11] = tempSnr[var12];
                        tempSnr[var12] = tSnr;
                    }
                }
            }

            for(var11 = 0; var11 < 10; ++var11) {
                LOG.V("NmeaAnalyzer", "----after----FIRST----10-------ELV:" + temp[var11] + "------SNR-----:" + tempSnr[var11]);
            }

            double var13 = 0.0D;

            for(int var14 = 0; var14 < 6; ++var14) {
                var13 += tempSnr[var14];
            }

            var13 /= 6.0D;
            LOG.V("NmeaAnalyzer", " ----avg-avg-----ELV------------" + var13);
            this.roverElvGpsSnr = (int)Math.round(var13);
        }
    }

    private void analyzeRoverBdsAvgElv(CopyOnWriteArrayList<MySatellite> sats) {
        if(sats.size() < 6) {
            this.roverElvGpsSnr = 0;
            LOG.V("NmeaAnalyzerrrr", "--002-YYYYYYYYYYYYYYYYYYYY----,roverGPSN," + this.roverGPSN + ",size," + sats.size() + ",roverBDSN," + this.roverBDSN + ",roverElvGpsSnr," + this.roverElvGpsSnr + ",roverElvBdsSnr," + this.roverElvBdsSnr);
        } else {
            double[] temp = new double[60];
            double[] tempSnr = new double[60];
            int countSat = 0;
            Iterator j = sats.iterator();

            while(j.hasNext()) {
                MySatellite avg = (MySatellite)j.next();
                if(2 == avg.getSystem()) {
                    temp[countSat] = avg.getElevation();
                    tempSnr[countSat] = avg.getSnr();
                    ++countSat;
                }
            }

            for(int var11 = 0; var11 < countSat; ++var11) {
                for(int var13 = var11; var13 < countSat; ++var13) {
                    if(temp[var11] < temp[var13]) {
                        double i = temp[var11];
                        temp[var11] = temp[var13];
                        temp[var13] = i;
                        double tSnr = tempSnr[var11];
                        tempSnr[var11] = tempSnr[var13];
                        tempSnr[var13] = tSnr;
                    }
                }
            }

            double var12 = 0.0D;

            for(int var14 = 0; var14 < 6; ++var14) {
                var12 += tempSnr[var14];
            }

            var12 /= 6.0D;
            LOG.V("NmeaAnalyzer", " ----avg-avg-----ELV------------" + var12);
            this.roverElvBdsSnr = (int)Math.round(var12);
        }
    }

    public interface NmeaCallback {
        void onNmeaOneBroadcast(String var1);

        void onNmeaUpdate(boolean[] var1);
    }
}
